package com.thxy.jxgl.mubiaoka.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.thxy.jxgl.filter.ToCh;
import com.thxy.jxgl.javaBean.khmbz;
import com.thxy.jxgl.javaBean.khxm;
import com.thxy.jxgl.mubiaoka.manager.MubiaokaManager;
import com.thxy.jxgl.mubiaoka.manager.MubiaozhiManager;

/**
 * Servlet implementation class MubiaozhiServlet
 */
public class MubiaozhiServlet extends HttpServlet {
	
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String method = request.getParameter("method") == null?"":request.getParameter("method");
		request.setCharacterEncoding("gbk");
        if("addmubiaozhi".equals(method))
        {
            khmbz mbz=(khmbz)request.getSession().getAttribute("mubiaozhi");
            request.getSession().removeAttribute("mubiaozhi");
            String fz_id=mbz.getFz_id();
            String fz_grade=mbz.getFz_grade();
            String fz_point=mbz.getFz_point();
            boolean ins=MubiaozhiManager.getInstance().addMbz(fz_id, fz_grade,fz_point);
        }else if ("xiugai".equals(method)) {
			
		}else if ("delemubiaozhi".equals(method)) {
			String mbzno=request.getParameter("mbzno");
			MubiaozhiManager.getInstance().deleMbz(mbzno);
		}
		else if ("editmubiaozhi".equals(method)) {
			String mbzno=request.getParameter("mbzno");
			String mbzgrade=request.getParameter("fz_grade").toString();
			String mbzpoint=request.getParameter("fz_point").toString();
			boolean upd=MubiaozhiManager.getInstance().updateMbz(mbzgrade,mbzpoint, mbzno);
		}
		List mbzList=new ArrayList();
		mbzList=MubiaozhiManager.getInstance().getMubiaozhi();
		request.getSession().setAttribute("mbzList", mbzList);
		request.getRequestDispatcher("/mbkgl/mubiaozhi.jsp").forward(request, response);

		}
	

}
